<template>
    <div>
        <table border="1">
            <tbody>
                <tr>
                    <th>账号</th>
                    <th>
                        <input type="text" v-model="data.LoginName">
                    </th>
                </tr>
                <tr>
                    <th>密码</th>
                    <th>
                        <input type="password"  v-model="data.LoginPwd">
                    </th>
                </tr>
                <tr>
                    <th>
                        <input type="button" value="登入" @click="Deng">
                    </th>
                </tr>
            </tbody>
        </table>
    </div>
</template>

<script setup lang="ts">
import axios from 'axios';
import { ref } from 'vue';
import { useRouter } from 'vue-router';

const data=ref({
    "LoginId": 0,
  "LoginName": "",
  "LoginPwd": ""
})

const router=useRouter();

const Deng=()=>{
    axios.get("https://localhost:7034/api/Member/Loginss",{params:data.value}).then(res=>{
        if(res.data.LoginId>0){
            alert('登入成功')
            router.push({path:"/AddView"})
        }
        if(res.data.LoginId==-1){
            alert('用户不存在')
        }
        if(res.data.LoginId==-2){
            alert('密码不正确')
        }
    })
}



</script>

